import Vue from 'vue'
import Router from 'vue-router'
import Layout from '../layout/index'

import FrontLayout from '@/views/front/layout/index'

Vue.use(Router)

export const constantRouterMap = [
  { path: '/login',
    meta: { title: '登录', noCache: true },
    // component: (resolve) => require(['@/views/Login'], resolve),
    component: (resolve) => require(['@/views/front/user/login'], resolve),
    hidden: true
  },
  {
    path: '/register',
    name: 'Register',
    meta: { title: '注册用户', noCache: true },
    component: resolve => require(['@/views/front/user/register'], resolve),
    hidden: true
  },
  {
    path: '/404',
    component: (resolve) => require(['@/views/features/404'], resolve),
    hidden: true
  },
  {
    path: '/401',
    component: (resolve) => require(['@/views/features/401'], resolve),
    hidden: true
  },
  {
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [
      {
        path: '/redirect/:path*',
        component: (resolve) => require(['@/views/features/redirect'], resolve)
      }
    ]
  },
  {
    path: '/dashboard',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: '/dashboard',
        component: (resolve) => require(['@/views/Home'], resolve),
        name: 'Dashboard',
        meta: { title: '首页', icon: 'index', affix: true, noCache: true }
      }
    ]
  },
  {
    path: '/',
    component: FrontLayout,
    redirect: 'index.html',
    children: [
      {
        path: 'index.html',
        name: 'Front',
        component: resolve => require(['@/views/front/index'], resolve),
        meta: { title: '首页', icon: 'index', affix: false, noCache: true },
        hidden: true
      },
      {
        path: 'center',
        name: 'Center',
        component: resolve => require(['@/views/front/user/center/index'], resolve),
        meta: { title: '个人中心', icon: 'index', affix: false, noCache: true },
        hidden: true
      },
      {
        path: 'search',
        name: 'search',
        meta: { title: '基金搜索', noCache: true },
        component: (resolve) => require(['@/views/front/search'], resolve),
        hidden: true
      },
      {
        path: 'layout',
        name: 'Layout',
        meta: { title: '布局测试', noCache: true },
        component: (resolve) => require(['@/views/front/layout'], resolve),
        hidden: true
      },
      {
        path: '/detail/:codeNumber',
        name: 'Detail',
        meta: { title: '基金详情', noCache: true },
        component: (resolve) => require(['@/views/front/detail'], resolve),
        params: {
          name
        },
        hidden: true
      },
      {
        path: 'subscribe',
        name: 'Subscribe',
        meta: { title: '我的订阅', noCache: true },
        component: (resolve) => require(['@/views/front/user/subscribe/index'], resolve),
        hidden: true
      },
      {
        path: 'trend',
        name: 'Trend',
        meta: { title: '趋势投资', noCache: true },
        component: (resolve) => require(['@/views/front/user/trend/index'], resolve),
        hidden: true
      }
    ]
  },
  {
    path: '/test',
    name: 'Test',
    meta: { title: '测试页面', noCache: true },
    component: resolve => require(['@/views/front/test/index'], resolve),
    hidden: true
  }
]

export default new Router({
  // mode: 'hash',
  mode: 'history',
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
